import React, { useState, useEffect } from 'react'; 
import { useHistory } from "react-router-dom";
import http from '../../model/http';
import code from "../../model/code";
import './acountList.less';
import '../../libs/font/iconfont.css'

import {  Button, List, Picker, Toast, InputItem, Modal } from 'antd-mobile';
import Header from '../../components/header/Header'
import { add } from 'lodash';
const Item = List.Item;

function AcountList() {
    const history = useHistory();
   
    const [hasSubAccount,setHasSubAccount] = useState(false) //是否有子账号
    const [acountList,setAcountList] = useState({})

     
    useEffect(async () => {
        getAccountList()
      
    }, [])

    

    const getAccountList =async () =>{
        // http://wxwork.gzsg.cn/wxwork/arsmo/wxworkAcountList?hosId=1&&userId=LiHao&managerId=1000127
        const list = await http.post('/arsmo/wxworkAcountList') 
        console.log("账号列表",list)
        // main_account=sg06208 main_user_name=熊黎迪 sub_account= sub_user_name=
        let {main_account,main_user_name,sub_account,sub_user_name} = list
        setAcountList({
            main_account,main_user_name,sub_account,sub_user_name
        })
 



    } 
    
    const add = ()=>{
           
        history.push('/bindOther',{
      
        })



    }

       
    


    return (
        <div>
            <div className="acountList">
               <List style={{ borderBottom: '1px solid #cccccc',paddingBottom:'25px'}} renderHeader={() => '主账号信息'}>
                    <div className='layout c3' >
                        <div style={{"fontSize":"14px"}}>主账号:{acountList.main_account}</div>
                        <div style={{"fontSize":"14px"}} className='mt12'>主账号姓名:{acountList.main_user_name}</div>
                    </div>
                    
                </List>
                <List style={{ borderBottom: '1px solid #cccccc',paddingBottom:'25px'}} renderHeader={() => '子账号信息'}>
                    <div className='layout c3'>
                        <div style={{"fontSize":"14px"}}>子账号:{acountList.sub_account}</div>
                        <div style={{"fontSize":"14px"}} className='mt12'>子账号姓名:{acountList.sub_user_name}</div>
                    </div>
                </List>
                {
                   ( !acountList.sub_account && !acountList.sub_user_name ) ?(
                    <Button type="warning" className="btn-class"  onClick={()=>{ add() }}>添加助诊账号</Button>
                   ):null
                }
               
                
            </div>
            <Header />

            


        </div>
    )
}
export default AcountList;
